<!-- 
 * Tournament bracket system for use in scenarios 
 * like sports, computer gaming or other games.
 * 
 * @link http://www.toggymedy.com
 * @license  GNU/GPL, ( http://www.gnu.org/licenses/gpl.txt )
 * @authors Team Excellence

 * The tournament bracket is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * Last update: 2009-11-27
 -->

<?php

	include_once('dbconnect.php');


	$data = mysql_query("SELECT * FROM turnering")
	or die(mysql_error());


	
		Print "<table border cellpadding=3>";
			Print "<tr><th>Turneringsid</th>";
			Print "<th>Spill</th>";
			Print "<th>Format</th>";
			Print "<th>Startet?</th>";
			Print "<th>Antall p&aring;meldte</th></tr>";

			while($info = mysql_fetch_array( $data ))
			{
				$query = mysql_query("SELECT * from paamelding where paamelding.turnid = $info[turnid]");
				$paam = mysql_num_rows( $query );
?>
				<form action="<?php $_SERVER['PHP_SELF']; ?>?side=startturnering" method='post' name=".$info['turnid'] .">
<?php				Print "<tr>";
						Print "<td><input type='hidden' name='turnid' value=".$info['turnid'] . ">".$info['turnid'] . "</td> ";
						Print "<td>".$info['spill'] . "</td> ";
						Print "<td>".$info['format'] . " </td>";
						Print "<td>";
						if ($info['startet'] > 0)
						{
							Print "Ja</td>";
						}
						else
						{
							Print" Nei </td>";
						}
						echo "<td>";

						echo "$paam";
						echo "</td>";

						Print "<td>";
						if($info['startet'] > 0)
						{
							echo "Turneringen er allerede startet!";
						}
						else if($paam < 8)
						{
							echo "For f&aring; p&aring;meldte";
						}
						else
						{
							echo "<input type='submit' name='submit' value='Start turneringen'></td>";
						}
					Print"</tr>";
				Print "</form>";
			
			}

		Print "</table>";

?>
